<style lang="scss" scoped>
  @import "../../utils/base.scss";

  .p_content {
    font-size: 13px;
    min-width: 100px;
    max-width: 200px;
    height: auto;
    word-wrap: break-word;
    word-break: break-all;
    overflow: hidden;
    padding-bottom: 4px;
  }

  .ivu-tooltip {
    width: 100%;
  }
</style>
<template>
  <div ref='base' class="quest_content" style="overflow-y:auto">
    <!-- 租户详情 -->
    <template id="baseInfo">
      <div class="qheader"
        :style="{borderBottom: ifedit ? '0px solid rgb(210,210,210)' : '1px solid rgb(210,210,210)',}">
        <p>提单人信息</p>
      </div>
      <div class="gcontent">
        <Form :model="applyinfo.base" :label-width="labelWidth" label-position="left" class="form form_left">
          <Row v-if="reqId != null && reqId != ''">
            <Col span="8">
            <FormItem label="工单ID：">
              <Input v-model="reqId" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem label="申请人姓名：">
              <Input v-model="applyinfo.base.userName" :readonly="readonly" />
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem label="申请人身份证:">
              <Input v-model="applyinfo.base.applyCardId" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem label="申请人电话：">
              <Input v-model="applyinfo.base.telephone" :readonly="readonly" />
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem label="申请人邮箱:">
              <Input v-model="applyinfo.base.email" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem label="申请人单位：">
              <Input v-model="applyinfo.base.applydept" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>
        </Form>
      </div>

    </template>

    <div id="projectInfo">
      <div class="qheader"
        :style="{borderBottom: ifedit ? '0px solid rgb(210,210,210)' : '1px solid rgb(210,210,210)',}">
        <p>入驻项目信息</p>
      </div>
      <div class="gcontent">
        <Form ref="projectInfo" :rules="projectInfoValidate" :model="applyinfo.projectInfo" :label-width="labelWidth"
          label-position="left" class="form form_left">
          <Row>
            <Col span="8">
            <FormItem label="工单主题：" prop="reqSubject">
              <Input v-model="applyinfo.reqSubject" :readonly="ifedit" placeholder="XX租户申请+XX型服务器+数量" />
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem label="入驻资源池：" prop="entrySysId">
              <Input v-if="ifedit" v-bind:value="applyinfo.remark.entrySysName" :readonly="ifedit" />
              <Select v-else v-model="applyinfo.remark.entrySysId" @on-change="checkSysName">
                <Option :value="i.id" v-for="(i,index) in allSysLists" :key="index">{{i.sysName}}</Option>
              </Select>
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem label="提单租户：" prop="roleId">
              <Input v-if="ifedit" v-model="applyinfo.projectInfo.roleName" :readonly="readonly" />
              <Select v-else v-model="applyinfo.projectInfo.roleId" @on-change="checkRole" :disabled="ifedit">
                <Option :value="i.id" v-for="(i,index) in roleList" :key="index">{{i.tenant_name}}</Option>
              </Select>
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem label="关联项目：" :prop="!ifedit?'projectId':''">
              <Input v-if="ifedit" v-model="applyinfo.projectInfo.projectName" :readonly="readonly" />
              <Select v-else v-model="applyinfo.projectInfo.projectId" @on-change="setProjectName" :disabled="ifedit">
                <Option :value="item.id" v-for="(item,index) in projectList" :key="index">{{item.project}}</Option>
              </Select>
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem label="开始日期：">
              <Input v-model="applyinfo.projectInfo.entryStartTime" :readonly="readonly" />
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem label="结束日期：">
              <Input v-model="applyinfo.projectInfo.entryEndTime" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem label="入驻周期：">
              <Input v-model="applyinfo.projectInfo.entryCycle" :readonly="readonly" />
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <!-- <FormItem label="入驻位置：">
								<Input v-model="applyinfo.projectInfo.entryPosition" :readonly="readonly" />
							</FormItem> -->
            <FormItem label="项目类型：">
              <Input v-model="applyinfo.projectInfo.projectType" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem label="是否签订合同：">
              <Input v-model="applyinfo.projectInfo.isContract" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem label="项目经理：">
              <Input v-model="applyinfo.projectInfo.projectManager" :readonly="readonly" />
            </FormItem>
            </Col>
            <Col span="8" class="col_left">
            <FormItem label="经理联系方式:">
              <Input v-model="applyinfo.projectInfo.managerTel" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="8">
            <FormItem label="运营人员：">
              <Input v-model="applyinfo.projectInfo.business" :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>
          <Row>
            <Col span="22" style="width:96.666667%">
            <FormItem label="项目主要功能介绍：">
              <Input v-model="applyinfo.projectInfo.projectDoc" type="textarea" :autosize="{minRows: 4,maxRows: 6}"
                :readonly="readonly" />
            </FormItem>
            </Col>
          </Row>
        </Form>
      </div>
    </div>

    <!-- 资源清单 -->
    <div id="resourceInfo">
      <div class="qheader"
        :style="{borderBottom: ifedit ? '0px solid rgb(210,210,210)' : '1px solid rgb(210,210,210)',}">
        <p>申请物理机资源</p>
      </div>
      <div class="gcontent" style="padding-bottom:10px;">
        <template>
          <Form :label-width="labelWidth" label-position="left" class="form form_left">
            <Row v-show="!ifedit || applyinfo.severs.length != 0">
              <Col span="22" style="width:96.666667%">
              <template>
                <!-- <template> -->
                <Table :columns="resourcesInfo.severColumns" :data="applyinfo.severs" border>
                  <template slot-scope="{ row, index }" slot="severName">
                    <p v-if="ifedit">{{applyinfo.severs[index].severName}}</p>
                    <Select v-else v-model="applyinfo.severs[index].severId" :transfer="resourcesInfo.transfer"
                      @on-change="setSeverID(index)" :disabled="ifedit">
                      <template v-for="i in applyinfo.resourcesInfo.seversList ">
                        <Option :value="i.id" :label="i.severName">
                          <Tooltip max-width="300" :disabled="tooltipDisabled" placement="right-end" :transfer="true"
                            style="white-space: nowrap;">
                            <p style="width: 100%;">{{i.severName}}</p>
                            <div slot="content" style="font-size:0;">
                              <p class="p_content">CPU数量：{{i.cpuQuantity}}</p>
                              <p class="p_content">CPU型号：{{i.cpuDes}}</p>
                              <p class="p_content">网卡数量：{{i.ncquantity}}</p>
                              <p class="p_content">网卡型号：{{i.ncdes}}</p>
                              <p class="p_content">内存数量：{{i.ramQuantity}}</p>
                              <p class="p_content">内存型号：{{i.ramDes}}</p>
                              <p class="p_content">数据盘: {{i.dataVolumn + i.dataUnit}}</p>
                              <p class="p_content">系统盘: {{i.sysVolumn + i.sysUnit}}</p>
                            </div>
                          </Tooltip>
                        </Option>
                      </template>
                    </Select>
                  </template>
                  <template slot-scope="{ row, index }" slot="os">
                    <p v-if="ifedit">{{applyinfo.severs[index].os}}</p>
                    <Select v-else v-model="applyinfo.severs[index].os" :transfer="resourcesInfo.transfer"
                      :disabled="ifedit">
                      <Option value="suse">suse</Option>
                      <Option value="bc-linux">bc-linux</Option>
                    </Select>
                  </template>
                  <template slot-scope="{ row, index }" slot="sysRaid">
                    <p v-if="ifedit">{{applyinfo.severs[index].sysRaid}}</p>
                    <Select v-else v-model="applyinfo.severs[index].sysRaid" :transfer="resourcesInfo.transfer"
                      :disabled="ifedit">
                      <template v-for="item in applyinfo.resourcesInfo.seversList ">
                        <template v-if="item.id == applyinfo.severs[index].severId">
                          <Option v-for="(raid, k) in item.raidOptions" :key="k" :value="raid">{{raid}}</Option>
                        </template>
                      </template>
                    </Select>
                  </template>
                  <template slot-scope="{ row, index }" slot="dataRaid">
                    <p v-if="ifedit">{{applyinfo.severs[index].dataRaid}}</p>
                    <Select v-else v-model="applyinfo.severs[index].dataRaid" :transfer="resourcesInfo.transfer"
                      :disabled="ifedit">
                      <template v-for="item in applyinfo.resourcesInfo.seversList ">
                        <template v-if="item.id == applyinfo.severs[index].severId">
                          <Option v-for="(raid, k) in item.raidOptions" :key="k" :value="raid">{{raid}}</Option>
                        </template>
                      </template>
                    </Select>
                  </template>
                  <template slot-scope="{ row, index }" slot="place">
                    <p v-if="ifedit">{{applyinfo.severs[index].place}}</p>
                    <Select v-else v-model="applyinfo.severs[index].place" :transfer="resourcesInfo.transfer"
                      :disabled="ifedit">
                      <Option value="dmz域">dmz域</Option>
                      <Option value="核心域">核心域</Option>
                    </Select>
                  </template>
                  <template slot-scope="{ row, index }" slot="quantity">
                    <p v-if="ifedit">{{applyinfo.severs[index].quantity}}</p>
                    <InputNumber v-else :min="0" v-model="applyinfo.severs[index].quantity" :readonly="ifedit" />
                  </template>
                  <template slot-scope="{ row, index }" slot="purpose">
                    <p v-if="ifedit">{{applyinfo.severs[index].purpose}}</p>
                    <Input v-else v-model="applyinfo.severs[index].purpose" type="textarea"
                      :autosize="{minRows: 1,maxRows: 6}" :readonly="ifedit" />
                  </template>

                  <template slot-scope="{ row, index }" slot="action">
                    <Button v-if="!ifedit" @click="deleteRow(row, index)">删除</Button>
                    <Poptip :transfer="true" placement="top-end">
                      <Button>基础信息</Button>
                      <template v-if="ifedit">
                        <div slot="title">
                          {{applyinfo.severs[index].severName}}
                        </div>
                        <div slot="content">
                          <div slot="content" style="font-size:0;">
                            <p class="p_content">CPU数量: {{applyinfo.severs[index].cpuQuantity}}</p>
                            <p class="p_content">CPU型号: {{applyinfo.severs[index].cpuDes}}</p>
                            <p class="p_content">网卡数量: {{applyinfo.severs[index].ncquantity}}</p>
                            <p class="p_content">网卡型号: {{applyinfo.severs[index].ncdes}}</p>
                            <p class="p_content">内存数量: {{applyinfo.severs[index].ramQuantity}}</p>
                            <p class="p_content">内存型号: {{applyinfo.severs[index].ramDes}}</p>
                            <p class="p_content">数据盘:
                              {{applyinfo.severs[index].dataVolumn + applyinfo.severs[index].dataUnit}}</p>
                            <p class="p_content">系统盘:
                              {{applyinfo.severs[index].sysVolumn + applyinfo.severs[index].sysUnit}}</p>
                          </div>
                        </div>
                      </template>
                      <template v-else>
                        <div slot="title">
                          {{applyinfo.severs[index].severName}}
                        </div>
                        <div slot="content">
                          <div slot="content" style="font-size:0;">
                            <p class="p_content">CPU数量: {{applyinfo.severs[index].cpuQuantity}}</p>
                            <p class="p_content">CPU型号: {{applyinfo.severs[index].cpuDes}}</p>
                            <p class="p_content">网卡数量: {{applyinfo.severs[index].ncquantity}}</p>
                            <p class="p_content">网卡型号: {{applyinfo.severs[index].ncdes}}</p>
                            <p class="p_content">内存数量: {{applyinfo.severs[index].ramQuantity}}</p>
                            <p class="p_content">内存型号: {{applyinfo.severs[index].ramDes}}</p>
                            <p class="p_content">数据盘:
                              {{applyinfo.severs[index].dataVolumn + applyinfo.severs[index].dataUnit}}</p>
                            <p class="p_content">系统盘:
                              {{applyinfo.severs[index].sysVolumn + applyinfo.severs[index].sysUnit}}</p>
                          </div>
                        </div>
                      </template>
                    </Poptip>
                  </template>
                </Table>
                <!-- </template> -->
              </template>
              </Col>
            </Row>
            <!-- </CheckboxGroup> -->
          </Form>
        </template>
      </div>
    </div>

    <!-- 附件 -->
    <template>
      <div class="qheader" :style="{borderBottom: '1px solid rgb(210,210,210)',}">
        <p>附件</p>
      </div>
      <component ref="file" :is="'file'" :ifedit="ifedit" :filesList="filesList" v-model="applyinfo.files"></component>
    </template>
  </div>
</template>
<script>
  import ajax from "../../ajax_util"
  import Axios from 'axios'
  import notice from '../../base/notice'
  import file from './settledin/file'
  import fileUpload from '../../base/file_uploader'
  import fileModal from '../../base/file_modal'
  import fileDownload from '../../base/file_download'

  export default {
    name: "apply",
    components: {
      notice,
      file,
      fileUpload,
      fileModal,
      fileDownload
    },
    data() {
      const validatereqSubject = (rule, value, callback) => {
        if (this.applyinfo.reqSubject === '') {
          callback(new Error('填写工单标题'));
        } else {
          if (this.applyinfo.reqSubject.length > 50) {
            callback(new Error('最多填写50个字符'));
          } else {
            callback()
          }
        }
      };
      const validateEntrySysId = (rule, value, callback) => {
        if (this.applyinfo.remark.entrySysId == '') {
          callback(new Error('请选择工单入驻系统！'));
        } else {
          callback()
        }
      };
      return {
        allSysLists: [],
        tooltipDisabled: false,
        projectInfoValidate: {
          roleId: [{
            required: true,
            type: 'number',
            message: '请选择租户角色',
            trigger: 'change'
          }, ],
          projectId: [{
            required: true,
            type: 'number',
            message: '请选择关联项目',
            trigger: 'change'
          }, ],
          reqSubject: [{
            required: true,
            validator: validatereqSubject,
            trigger: 'blur'
          }, ],
          entrySysId: [{
            required: true,
            validator: validateEntrySysId,
            trigger: 'change'
          }, ],
        },

        readonly: true, //是否只读
        labelWidth: 140,
        //租户列表
        roleList: [],
        //项目名称
        projectList: [],
        projectList2: [],
        //资源清单相关基础信息
        resourcesInfo: {
          severColumns: [{
              title: "*服务类型",
              align: "center",
              width: 140,
              key: "severName",
              slot: "severName",
              fixed: 'left'
            },
            {
              title: "*操作系统",
              align: "center",
              width: 110,
              key: "id",
              slot: "os"
            },
            {
              title: "*raid方式",
              align: "center",
              children: [{
                  title: '*系统盘',
                  align: 'center',
                  width: 110,
                  slot: "sysRaid"
                },
                {
                  title: '*数据盘',
                  align: 'center',
                  width: 110,
                  slot: "dataRaid"
                },
              ]
            },
            {
              title: "*部署区域",
              align: "center",
              width: 110,
              slot: "place"
            },
            {
              title: "*台数",
              align: "center",
              width: 90,
              slot: "quantity"
            },
            {
              title: "测算依据/必要性说明",
              align: "center",
              minWidth: 180,
              slot: "purpose"
            },
            {
              slot: 'action',
              align: 'center',
              width: 166,
              fixed: 'right',
              renderHeader: (h, index) => {
                return h('div', [
                  h(!this.ifedit ? 'Button' : "", {
                    props: {
                      type: 'primary',
                      // size: 'small'
                    },
                    on: {
                      click: () => {
                        if (!this.ifedit) {
                          this.addRow()
                        }
                      }
                    }
                  }, !this.ifedit ? '新增' : "")
                ])
              }
            },
          ],
          severColumns2: [{
              title: "*服务类型",
              align: "center",
              width: 140,
              key: "severName",
              slot: "severName",
            },
            {
              title: "*操作系统",
              align: "center",
              width: 110,
              key: "id",
              slot: "os"
            },
            {
              title: "*raid方式",
              align: "center",
              children: [{
                  title: '*系统盘',
                  align: 'center',
                  width: 110,
                  slot: "sysRaid"
                },
                {
                  title: '*数据盘',
                  align: 'center',
                  width: 110,
                  slot: "dataRaid"
                },
              ]
            },
            {
              title: "*部署区域",
              align: "center",
              width: 110,
              slot: "place"
            },
            {
              title: "*台数",
              align: "center",
              width: 90,
              slot: "quantity"
            },
            {
              title: "测算依据/必要性说明",
              align: "center",
              // minWidth: 180,
              slot: "purpose"
            },
            {
              title: "基础信息",
              slot: 'des',
              align: 'center',
              width: 140,

            },
          ],

          transfer: true,
        },
        applyinfo: {
          reqSubject: "",
          remark: {
            "alloType": "",
            "dataApplyNum": 0,
            "entrySysId": 0,
            "entrySysName": "",
            "id": 0,
            "overId": 0,
            "reqId": 0,
            "severRelateReqId": 0
          },
          base: {
            applyDate: "",
            compId: "",
            userName: "",
            userId: "",
            applyCardId: "",
            telephone: "",
            email: "",
            applydept: ""
          },
          projectInfo: {
            roleId: "", //租户id
            roleName: "", //租户名称
            projectId: "", //关联项目ID
            projectName: "", //关联项目名称

            entryStartTime: "", //开始时间
            entryEndTime: "", //结束时间
            entryCycle: "", //入驻周期
            entryPosition: "", //入驻地址
            isContract: "", //是否签订合同
            projectType: "", //项目类型

            projectManager: "", //项目经理
            managerTel: "", //项目经理联系方式
            business: "",
            projectDoc: "", //项目介绍
          },
          projectInfo2: {
            reqId: "",
            reqDes: "",
            reqSubject: ""
          },
          resourcesInfo: {
            len: 0, //合并的行数
            resourceChcekList: [], //选择的申请资源清单列表
            resourceInfo: [], //资源清单字段详情
            seversList: [], //云服务字段列表
          },
          resources: [],
          severs: [],
          tools: {
            checkList: [], //选择的列表
            needResources: [],
            needSevers: []
          },
          datas: [],
          files: []
        }
      }
    },
    created: function() {},
    mounted: function() {
      console.log(this.$store.state.tabs)
      this.getResourceList(); //获取表单基础信息
      this.getSys()
    },

    methods: {
      checkSysName(id) {
        this.applyinfo.remark.entrySysName = this.allSysLists.find(e => e.id == id).sysName
      },
      getSys() {
        var url = this.CONFIG.progress_url + "/system-map/for/paas"
        var that = this;
        ajax.get({
          url: url,
          that: that,
          params: null,
          success: function(data) {
            that.allSysLists = data
          }
        })
      },
      //获取租户角色
      getRoleLis(userId) {
        console.log("-----------------")
        var url = this.CONFIG.url_know + "/tenantByUserId/" + userId
        var that = this;
        ajax.get({
          url: url,
          that: that,
          params: null,
          success: function(data) {
            that.roleList = data

            if (that.applyinfo.projectInfo.roleId != null && that.applyinfo.projectInfo.roleId != undefined &&
              that.applyinfo
              .projectInfo.roleId != "") {
              that.checkRole(that.applyinfo.projectInfo.roleId)
            }
          }
        })
      },
      // 获取提交表单人基本信息
      getApplyUser(userId) {
        var that = this;
        var url = this.CONFIG.url_know + '/user/' + userId;
        ajax.get({
          url: url,
          that: that,
          success: function(data) {
            console.log("user----->", data)
            that.applyinfo.base.userName = data.user_name
            that.applyinfo.base.userId = data.id
            that.applyinfo.base.applyCardId = data.id_card
            that.applyinfo.base.telephone = data.phone
            that.applyinfo.base.email = data.email
            that.applyinfo.base.applydept = that.processInfo.dptName
          }
        })
      },
      //获取草稿详情
      getDrafts() {
        var url = this.CONFIG.base_url_test + "/draft/content/" + this.draftsId
        var that = this;
        ajax.get({
          url: url,
          that: that,
          params: null,
          success: function(data) {
            console.log("---getDrafts---------", data);
            that.applyinfo.reqSubject = data.req.puslicInfo.reqSubject
            that.applyinfo.base = data.req.base
            that.applyinfo.severs = data.req.object.severs
            that.getRoleLis(data.req.base.userId)
            // that.checkRole(data.req.object.projectInfo.roleId)
            that.applyinfo.projectInfo = data.req.object.projectInfo
            that.applyinfo.files = data.req.files
            that.applyinfo.remark.entrySysId = data.req.object.remark.entrySysId
          }
        })
      },

      //获取草稿或者表单详情
      setInfo() {
        if (this.reqId != null) {
          this.getApplyInfo(); //获取表单详情
        } else if (this.draftsId != null) {
          console.log("获取草稿---------->")
          this.getDrafts()
        } else {
          this.getUserInfo(); // 获取登录用户信息
        }
      },
      getUserInfo() {
        console.log("获取用户基础信息---2---->", this.$store.state.user)
        var temp = this.$store.state.user
        this.getRoleLis(temp.id); //获取角色列表
        this.applyinfo.base.userName = temp.user_name
        this.applyinfo.base.userId = temp.id
        this.applyinfo.base.applyCardId = temp.id_card
        this.applyinfo.base.telephone = temp.phone
        this.applyinfo.base.email = temp.email
        this.applyinfo.base.applydept = temp.department
      },
      getApplyInfo() {
        var data = this.processInfo
        console.log("data->", data)
        this.getApplyUser(data.base.userFBean.id)
        this.applyinfo.base.applydept = data.dptName
        this.applyinfo.reqSubject = this.processInfo.reqSubject
        this.applyinfo.files = this.processInfo.files
        if (this.processInfo.content.remark != undefined &&
          this.processInfo.content.remark != null &&
          this.processInfo.content.remark != "") {
          this.allSysLists.forEach(item => {
            if (item.id == data.content.remark.entrySysId) {
              data.content.remark.entrySysName = item.sysName
            }
          })
          this.applyinfo.remark = this.processInfo.content.remark
        }
        if (this.isEdit == 1) {
          if (data.base.project != null && data.base.project != undefined) {
            this.getRoleLis(data.base.userFBean.id)
            this.checkRole(data.base.role.id)
          }
        }
        this.setProjectInfo(data.base.project)
        this.setSeverInfo(data.content.severs)

      },
      setSeverInfo(sever) {
        console.log("sever-------", sever)
        this.applyinfo.severs = []
        sever.forEach(item => {
          var temp = []
          temp = item.service
          temp.quantity = item.quantity
          temp.purpose = item.purpose
          temp.severId = item.severId
          temp.place = item.place
          temp.sysRaid = item.sysRaid
          temp.dataRaid = item.dataRaid
          temp.os = item.os
          this.applyinfo.severs.push(temp)
        })
      },
      //设置项目基础详情
      setProjectInfo(data) {
        if (data != undefined && data != null) {
          var info = {}
          info.roleId = data.tenant_id
          info.roleName = data.tenant_name
          info.projectId = data.id
          info.projectName = data.project
          info.entryStartTime = this.utils.formatDate(new Date(data.create_time * 1000), "yyyy-MM-dd")
          info.entryEndTime = this.utils.formatDate(new Date(data.end_time * 1000), "yyyy-MM-dd")
          //info.entryStartTime = data.create_time;
          //info.entryEndTime = data.end_time;
          info.entryCycle = data.cycle
          info.entryPosition = data.position
          info.isContract = data.isContract
          info.projectType = data.projectType
          info.projectManager = data.manager
          info.managerTel = data.manager_phone
          if (data.business == undefined || data.business == null || data.business == "") {
            info.business = data.tenant_business
          } else {
            info.business = data.business
          }
          info.projectDoc = data.des
          this.applyinfo.projectInfo = info
          console.log(this.applyinfo.projectInfo)
        }
      },

      //资源清单_获取基础信息
      getResourceList() {
        console.log("获取基础信息---->")
        var url = this.CONFIG.progress_url + "/service-list"
        var that = this;
        ajax.get({
          url: url,
          that: that,
          params: null,
          success: function(data) {
            that.applyinfo.resourcesInfo.seversList = data.severList
            that.setInfo()
          }
        })
      },
      addRow() { //资源清单，添加
        this.applyinfo.severs.push({
          "cpuQuantity": 0,
          "dataRaid": "",

          "os": "",
          "overId": 0,
          "purpose": "",
          "quantity": 0,
          "ramQuantity": 0,
          "severId": 0,
          "severName": "",
          "status": 0,
          "sysRaid": "",
          "place": "",
          "sysUnit": "",
          "sysVolumn": 0,
          "dataUnit": "",
          "dataVolumn": 0,
        })
      },
      setSeverID(index) {
        this.tooltipDisabled = true
        console.log(this.tooltipDisabled)
        this.applyinfo.resourcesInfo.seversList.some(item => {
          if (item.id == this.applyinfo.severs[index].severId) {
            console.log(item)
            this.applyinfo.severs[index].severName = item.severName
            this.applyinfo.severs[index].ramQuantity = item.ramQuantity
            this.applyinfo.severs[index].ramDes = item.ramDes
            this.applyinfo.severs[index].cpuQuantity = item.cpuQuantity
            this.applyinfo.severs[index].cpuDes = item.cpuDes

            this.applyinfo.severs[index].sysUnit = item.sysUnit
            this.applyinfo.severs[index].sysVolumn = item.sysVolumn
            this.applyinfo.severs[index].dataUnit = item.dataUnit
            this.applyinfo.severs[index].dataVolumn = item.dataVolumn
            this.applyinfo.severs[index].ncquantity = item.ncquantity
            this.applyinfo.severs[index].ncdes = item.ncdes
            return true
          }
        })
        setTimeout(() => {
          this.$nextTick(() => {
            this.tooltipDisabled = false
            console.log(this.tooltipDisabled)
          })
        }, 500)
      },
      deleteRow(roew, index) { //删除资源清单
        this.applyinfo.severs.splice(index, 1);
      },
      //选择租户
      checkRole(roleId) {
        if (roleId != "") {
          console.log('rolelist:', this.roleList)
          //this.applyinfo.projectInfo = {}
          this.roleList.some(item => {
            if (roleId == item.id) {
              console.log("=====item========", item);
              this.applyinfo.projectInfo.roleId = roleId
              this.applyinfo.projectInfo.roleName = item.tenant_name
              this.projectList = item.projects;
              return true
            }
          })

          // var that = this;
          // var url = this.CONFIG.url_know + "/getProjects/" + roleId
          // ajax.get({
          //   url: url,
          //   that: that,
          //   params: null,
          //   success: function(data) {
          //     console.log("---------data-----", data)
          //     that.projectList = data
          //   }
          // })
        }

      },

      // 设置项目名称
      setProjectName(value) {
        this.projectList.some(item => {
          if (item.id === value) {
            // this.applyinfo.projectInfo.projectName = item.projectName
            this.setProjectInfo(item)
            return true
          }
        })

      },

      //获取表单信息并加以处理
      getInfo() {
        var temp = this.applyinfo
        var info = {
          base: {},
          object: {
            projectInfo: {},
            resources: [],
            severs: [],
            tools: [],
            datas: [],
            alloRemarkModel: {
              relateReqId: ""
            },
            remark: {
              entrySysId: "",
              entrySysName: ""
            }

          },
          files: []
        }

        info.base = temp.base
        info.base.dptName = this.applyinfo.base.applydept
        info.base.roleId = this.applyinfo.projectInfo.roleId
        info.base.projectId = this.applyinfo.projectInfo.projectId
        info.object.projectInfo = temp.projectInfo
        info.object.alloRemarkModel.relateReqId = temp.projectInfo2.reqId
        info.object.remark.entrySysId = temp.remark.entrySysId
        info.object.remark.entrySysName = temp.remark.entrySysName
        info.files = this.applyinfo.files

        //处理resourceList
        info.object.severs = temp.severs
        var publicInfo = this.utils.setPublicInfoInfo(temp.reqSubject, 0, 0, temp.projectInfo.projectDoc)
        info.puslicInfo = publicInfo
        console.log("------info------", info);
        return info;
      },
      //校验是否允许提交
      validate() {
        var isSubmit = false
        this.$refs["projectInfo"].validate((valid) => {
          if (valid) {
            var check = this.checkResourceInfo()
            isSubmit = !check
          } else {
            this.$refs.base.scrollTop = document.getElementById("projectInfo").offsetTop - 100
            this.$Message.error('请填写必填项');
          }
        })
        return isSubmit
      },
      //校验资源申请表单
      checkResourceInfo() {
        var b = false
        if (this.applyinfo.severs.length < 1) {
          console.log("校验资源申请表单")
          this.$Message.error('请填写至少一条物理机策略信息！');
          b = true
        } else {
          this.applyinfo.severs.some((i1, index) => {
            if (i1.severName === undefined || i1.severName === "") {
              this.$Message.warning({
                content: "请选择“服务类型”",
                duration: 3
              })
              b = true
              return true
            } else if (i1.os === '') {
              this.$Message.warning({
                content: "请选择“操作系统”",
                duration: 3
              })
              b = true
              return true
            } else if (i1.sysRaid === '') {
              this.$Message.warning({
                content: "请选择“系统盘”",
                duration: 3
              })
              b = true
              return true
            } else if (i1.dataRaid === '') {
              this.$Message.warning({
                content: "请选择“数据盘”",
                duration: 3
              })
              b = true
              return true
            } else if (i1.place === '') {
              this.$Message.warning({
                content: "请选择“部署区域”",
                duration: 3
              })
              b = true
              return true
            } else if (i1.quantity === '' || i1.quantity == 0) {
              this.$Message.warning({
                content: "请填写“台数”",
                duration: 3
              })
              b = true
              return true
            }
          })
        }
        if (b) {
          this.$refs.base.scrollTop = document.getElementById("resourceInfo").offsetTop - 100
        }
        return b;
      },

      // 获取处理时需要提交的参数
      getHandleParams(handleInfo) {
        handleInfo.reqSubject = this.applyinfo.reqSubject
        handleInfo.startTime = 0
        handleInfo.hopeTime = 0
        handleInfo.reqDes = this.applyinfo.projectInfo.projectDoc
        handleInfo.isEdit = this.isEdit;
        console.log("aaaa-------->", this.ifedit, this.isEdit == 1)
        handleInfo.isChangeContent = 0;
        if (!this.ifedit) {
          handleInfo.isChangeContent = 1;
        }
        if (this.isEdit == 1) {
          handleInfo.roleId = this.applyinfo.projectInfo.roleId;
          handleInfo.projectId = this.applyinfo.projectInfo.projectId;
          handleInfo.content = this.getInfo()
        }
      },
      //处理页面获取下一步处理人需要的参数
      getHandleUserParams(opOptions) {
        var param = {}
        param.vari = opOptions
        param.roleId = this.applyinfo.projectInfo.roleId;
        param.projectId = this.applyinfo.projectInfo.projectId;
        return param
      },

    },
    props: {
      isEdit: {},
      value: {
        dafault: false
      },
      ifedit: {
        type: Boolean,
        default: false,
      },
      reqId: {
        default: null
      },
      draftsId: {
        default: null
      },
      filesList: {},
      processInfo: {},
      ishidden: {
        type: Boolean,
        default: false,
      },
    },
    computed: {
      newValue: {
        get: function() {
          return this.value;
        },
        set: function(value) {
          this.$emit('input', value);
        }
      },
    },
    watch: {
      ifedit(Val) {},
      processInfo(Val) {
        this.getApplyInfo()
      }
    }

  }
</script>
